home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / helper / source / keyword.c < prev    next >
Text File  |  1991-10-18  |  19KB  |  767 lines

  1. /*
  2.     KEYWORD.C
  3.  
  4.     1991.01.11  make by Ken
  5. */
  6. #include    <stdio.h>
  7. #include    <stdlib.h>
  8. #include    <string.h>
  9. #include    <ctype.h>
  10. #include    <mos.h>
  11. #include    "scrn.h"
  12. #include    "keyword.h"
  13. #include    "graphic.h"
  14. #include    "dir.h"
  15. #include    "file.h"
  16. #include    "event.h"
  17. #include    "coldef.h"
  18.  
  19. #define    TRUE    1
  20. #define    FALSE    0
  21. #define    ERR    (-1)
  22.  
  23. #define KEY_HAS     8
  24.  
  25.        int    prg_max=0;
  26.        int    key_max=0;
  27.        int    prg_cnt=0;
  28.        int    prg_hit=0;
  29.        int      prg_ofs=0;
  30.        char    *crent_drive=NULL;
  31.        PRGPTR    *prg_top=NULL;
  32. static PRGPTR    *prg_btm=NULL;
  33. static KEYPTR    *key_now=NULL;
  34.        KEYPTR   *key_tbl[KEY_MAX];
  35. static KEYPTR   *key_hash[KEY_HAS]={
  36.             NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
  37.        PRGPTR    *prg_tbl[PRG_MAX];
  38.  
  39. char    *strdup(char *str)
  40. {
  41.     char    *p;
  42.  
  43.     if ( (p = (char *)malloc(strlen(str)+1)) != NULL )
  44.     strcpy(p,str);
  45.     return p;
  46. }
  47. static int  hash_calc(char *str)
  48. {
  49.     int     hs=0;
  50.  
  51.     while ( *str != '\0' )
  52.         hs = hs * 31 + *(str++);
  53.     return (hs & (KEY_HAS-1));
  54. }
  55. static KEYPTR *key_srch(char *key)
  56. {
  57.     int     hs;
  58.     KEYPTR  *kp;
  59.  
  60.     hs = hash_calc(key);
  61.     kp = key_hash[hs];
  62.     while ( kp != NULL ) {
  63.         if ( strcmp(key,kp->key) == 0 )
  64.         return kp;
  65.         kp = kp->next;
  66.     }
  67.  
  68.     if ( (kp = (KEYPTR *)malloc(sizeof(KEYPTR))) == NULL )
  69.         return NULL;
  70.  
  71.     kp->next = key_hash[hs];
  72.     key_hash[hs] = kp;
  73.  
  74.     kp->key = strdup(key);
  75.     kp->flg = kp->cnt = 0;
  76.     kp->over = kp->grop = NULL;
  77.  
  78.     return kp;
  79. }
  80. static void key_set(char *key,PRGPTR *pp)
  81. {
  82.     int     i,hs;
  83.     KEYPTR  *kp;
  84.  
  85.     hs = hash_calc(key);
  86.     kp = key_hash[hs];
  87.     while ( kp != NULL ) {
  88.         if ( strcmp(key,kp->key) == 0 ) {
  89.         key_now = kp;
  90.         if ( kp->grop != NULL )
  91.         kp = kp->grop;
  92.             while ( kp->cnt >= PRG_QUE ) {
  93.         for ( i = 0 ; i < kp->cnt ; i++ ) {
  94.             if ( kp->prog[i] == pp )
  95.             return;
  96.         }
  97.                 if ( kp->over == NULL ) {
  98.                     if ( (kp->over =
  99.                          (KEYPTR *)malloc(sizeof(KEYPTR))) == NULL )
  100.                         return;
  101.                     kp = kp->over;
  102.             kp->cnt = 0;
  103.             kp->over = NULL;
  104.                 } else
  105.                     kp = kp->over;
  106.             }
  107.             goto ENDOF;
  108.         }
  109.         kp = kp->next;
  110.     }
  111.  
  112.     if ( (kp = (KEYPTR *)malloc(sizeof(KEYPTR))) == NULL )
  113.         return;
  114.  
  115.     kp->next = key_hash[hs];
  116.     key_hash[hs] = kp;
  117.  
  118.     kp->key = strdup(key);
  119.     kp->flg = kp->cnt = 0;
  120.     kp->over = kp->grop = NULL;
  121.     key_now = kp;
  122.  
  123.     if ( key_max < KEY_MAX ) {
  124.     KEY_putstr(key_max,kp->key);
  125.     key_tbl[key_max++] = kp;
  126.     }
  127.  
  128. ENDOF:
  129.     if ( pp != NULL ) {
  130.     for ( i = 0 ; i < kp->cnt ; i++ ) {
  131.         if ( kp->prog[i] == pp )
  132.         return;
  133.     }
  134.     kp->prog[kp->cnt++] = pp;
  135.     }
  136. }
  137. static    char    *chk_drv(char *dir)
  138. {
  139.     static char tmp[BUFSIZ];
  140.  
  141.     if ( dir[0] != '\0' && dir[1] == ':' )
  142.     return dir;
  143.  
  144.     if ( crent_drive == NULL )
  145.     return dir;
  146.  
  147.     strcpy(tmp,crent_drive);
  148.     strcat(tmp,dir);
  149.     return tmp;
  150. }
  151. int    DB_init(char *file)
  152. {
  153.     int     i,n;
  154.     FILE    *fp;
  155.     PRGPTR  *pp=NULL;
  156.     KEYPTR  *kp,*tp;
  157.     char    *p,*s;
  158.     char    tmp[BUFSIZ];
  159.     char    key[BUFSIZ];
  160.  
  161.     prg_max = key_max = 0;
  162.  
  163.     if ( (fp = fopen(file,"r")) == NULL )
  164.     return ERR;
  165.  
  166.     while ( fgets(tmp,BUFSIZ,fp) != NULL ) {
  167.  
  168.     if ( (p = strchr(tmp,'\n')) != NULL )
  169.         *p = '\0';
  170.  
  171.     if ( tmp[0] == '\0' || tmp[0] == '#' )
  172.         continue;
  173.  
  174.     if ( strncmp(tmp,"DRIVE:",6) == 0 ) {
  175.         p = &(tmp[6]); while ( isspace(*p) ) p++;
  176.         if ( *p == '\0' )
  177.         continue;
  178.         crent_drive = strdup(p);
  179.         continue;
  180.     }
  181.  
  182.     if ( strncmp(tmp,"PROGRAM:",8) == 0 ) {
  183.         p = &(tmp[8]); while ( isspace(*p) ) p++;
  184.         if ( *p == '\0' )
  185.         continue;
  186.  
  187.         if ( (pp = (PRGPTR *)malloc(sizeof(PRGPTR))) == NULL )
  188.         break;
  189.  
  190.         pp->next = prg_top;
  191.         prg_top = pp;
  192.  
  193.         prg_max++;
  194.         pp->flg = pp->copycnt = pp->bits = 0;
  195.         pp->name = strdup(p);
  196.         pp->make = pp->readme = pp->manual = pp->dir = NULL;
  197.         continue;
  198.     }
  199.  
  200.     if ( strncmp(tmp,"KEYWORD:",8) == 0 ) {
  201.         p = &(tmp[8]);
  202.         while ( *p != '\0' ) {
  203.         while ( isspace(*p) ) p++;
  204.         for ( s = key ; !isspace(*p) && *p != '\0' ; )
  205.              *(s++) = *(p++);
  206.         *s = '\0';
  207.         if ( key[0] != '\0' )
  208.             key_set(key,pp);
  209.         }        
  210.         continue;
  211.     }
  212.  
  213.     if ( strncmp(tmp,"GROUP:",6) == 0 ) {
  214.         tp = NULL;
  215.         p = &(tmp[6]);
  216.         while ( *p != '\0' ) {
  217.         while ( isspace(*p) ) p++;
  218.         for ( s = key ; !isspace(*p) && *p != '\0' ; )
  219.              *(s++) = *(p++);
  220.         *s = '\0';
  221.         if ( key[0] != '\0' ) {
  222.             if ( tp == NULL ) {
  223.                 key_set(key,NULL);
  224.             tp = key_now;
  225.             } else {
  226.             if ( (kp = key_srch(key)) != NULL )
  227.                 kp->grop = tp;
  228.             }
  229.         }
  230.         }        
  231.         continue;
  232.     }
  233.  
  234.     if ( pp == NULL )
  235.         continue;
  236.  
  237.     if ( strncmp(tmp,"MAKE:",5) == 0 ) {
  238.         p = &(tmp[6]); while ( isspace(*p) ) p++;
  239.         if ( *p != '\0' )
  240.         pp->make = strdup(p);
  241.  
  242.     } else if ( strncmp(tmp,"README:",7) == 0 ) {
  243.         p = &(tmp[7]); while ( isspace(*p) ) p++;
  244.         if ( *p != '\0' )
  245.         pp->readme = strdup(chk_drv(p));
  246.  
  247.     } else if ( strncmp(tmp,"MANUAL:",7) == 0 ) {
  248.         p = &(tmp[7]); while ( isspace(*p) ) p++;
  249.         if ( *p != '\0' )
  250.         pp->manual = strdup(chk_drv(p));
  251.  
  252.     } else if ( strncmp(tmp,"COPY:",5) == 0 ) {
  253.         p = &(tmp[5]);
  254.         while ( *p != '\0' ) {
  255.         while ( isspace(*p) ) p++;
  256.         for ( s = key ; !isspace(*p) && *p != '\0' ; )
  257.              *(s++) = *(p++);
  258.         *s = '\0';
  259.         if ( key[0] != '\0' && pp->copycnt < 16 )
  260.             pp->copy[pp->copycnt++] = strdup(chk_drv(key));
  261.         }        
  262.  
  263.     } else if ( strncmp(tmp,"DIR:",4) == 0 ) {
  264.         p = &(tmp[4]); while ( isspace(*p) ) p++;
  265.         if ( *p != '\0' )
  266.         pp->dir = strdup(chk_drv(p));
  267.  
  268.     }
  269.  
  270.     }
  271.     fclose(fp);
  272.  
  273. /***************************************************
  274.     for ( i = 0 ; i < 4 && i < key_max ; i++ ) {
  275.     kp = key_tbl[i];
  276.     do {
  277.         for ( n = 0 ; n < kp->cnt ; n++ )
  278.             kp->prog[n]->bits |= (1 << i);
  279.         kp = kp->over;
  280.         } while ( kp != NULL );
  281.     }
  282. *****************************************************/
  283.  
  284.     return FALSE;
  285. }
  286. void    PRG_alldisp(int ofs)
  287. {
  288.     int     i;
  289.     PRGPTR  *pp;
  290.  
  291.     prg_ofs = ofs;
  292.     i = 0;
  293.     for ( pp = prg_top ; prg_cnt > 0 && pp != NULL ; pp = pp->next ) {
  294.     if ( pp->flg >= prg_cnt ) {
  295.         if ( i >= ofs && (i - ofs) < PRG_MAX ) {
  296.         PRG_disp((i-ofs),pp->name,pp->make,pp->bits);
  297.         prg_tbl[i-ofs] = pp;
  298.         }
  299.         i++;
  300.     }
  301.     }
  302.     prg_hit = i;
  303.  
  304.     MENU_mask(BACK_NO,ofs > 0 ? ON:OFF);
  305.     MENU_mask(NEXT_NO,(i-ofs) > PRG_MAX ? ON:OFF);
  306.     MENU_mask(CLER_NO,prg_cnt > 0 ? ON:OFF);
  307.  
  308.     while ( i >= ofs && (i - ofs) < PRG_MAX ) {
  309.     PRG_disp((i - ofs),"","",0);
  310.     prg_tbl[i-ofs] = NULL;
  311.     i++;
  312.     }
  313.  
  314.     if ( prg_cnt == 0 )
  315.     MSG2_disp("%24s","");
  316.     else if ( prg_hit == 0 )
  317.     MSG2_disp("該当する作品がありません");
  318.     else
  319.     MSG2_disp("%3d個の作品があります   ",prg_hit);
  320. }
  321. void    KEY_clic(int no)
  322. {
  323.     int     i,cd;
  324.     KEYPTR  *kp;
  325.  
  326.     if ( no >= key_max )
  327.     return;
  328.  
  329.     kp = key_tbl[no];
  330.     if ( (kp->flg = (kp->flg == 0 ? 1:0)) == 0 ) {
  331.     cd = (-1);
  332.     } else {
  333.     cd = 1;
  334.     }
  335.  
  336.     KEY_disp(no);
  337.     prg_cnt += cd;
  338.     do {
  339.     for ( i = 0 ; i < kp->cnt ; i++ )
  340.         kp->prog[i]->flg += cd;
  341.     kp = kp->over;
  342.     } while ( kp != NULL );
  343.  
  344.     PRG_alldisp(0);
  345. }
  346. void    KEY_cler(void)
  347. {
  348.     int     i;
  349.     PRGPTR  *pp;
  350.  
  351.     for ( i = 0 ; i < key_max ; i++ ) {
  352.     if ( key_tbl[i]->flg != 0 ) {
  353.         key_tbl[i]->flg = 0;
  354.         KEY_disp(i);
  355.     }
  356.     }
  357.  
  358.     for ( pp = prg_top ; pp != NULL ; pp = pp->next )
  359.     pp->flg = 0;
  360.  
  361.     for ( i = 0 ; i < PRG_MAX ; i++ ) {
  362.     PRG_disp(i,"","",0);
  363.     prg_tbl[i] = NULL;
  364.     }
  365.  
  366.     prg_cnt = prg_hit = 0;
  367.  
  368.     MENU_mask(BACK_NO,OFF);
  369.     MENU_mask(NEXT_NO,OFF);
  370.     MENU_mask(CLER_NO,OFF);
  371.  
  372.     MSG2_disp("%24s","");
  373. }
  374. void    PRG_status(void)
  375. {
  376.     MENU_mask(BACK_NO,prg_ofs > 0 ? ON:OFF);
  377.     MENU_mask(NEXT_NO,(prg_hit - prg_ofs) > PRG_MAX ? ON:OFF);
  378.     MENU_mask(CLER_NO,prg_cnt > 0 ? ON:OFF);
  379. }
  380. void    PRG_back(void)
  381. {
  382.     if ( prg_ofs <= 0 )
  383.     return;
  384.     PRG_alldisp(prg_ofs - PRG_MAX);
  385. }
  386. void    PRG_next(void)
  387. {
  388.     if ( (prg_ofs + PRG_MAX) >= prg_hit )
  389.     return;
  390.     PRG_alldisp(prg_ofs + PRG_MAX);
  391. }
  392.  
  393. /*************************************************************
  394. 01234567890123456789012345678901234567890123456789012345678901234567890123456789                01234567890123456789012345678901234567890123456
  395.                 +---------------------------------------------+
  396.                 | PROGRAM  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | 
  397.                 | MAKE     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  398.                 | KEYWORD  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  399.                 | COPY     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  400.                 | README   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  401.                 | MANUAL   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  402.                 | DIR      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
  403.                 |             | 設  定 | | 終  了 |           |
  404.                 +---------------------------------------------+
  405. **************************************************************/
  406.  
  407. extern char    index_file[];
  408. extern int    cut_mode;
  409. extern char    cut_buf[2][128];
  410.  
  411. #define    FILE_IDX    index_file
  412.  
  413. #define    FSEL_X1        (5*8)
  414. #define    FSEL_Y1        (250)
  415. #define    FSEL_X2        (75*8)
  416. #define    FSEL_Y2        (FSEL_Y1+200)
  417.  
  418. #define    FSEL_PROG_X    (FSEL_X1+11*8)
  419. #define    FSEL_PROG_Y    (FSEL_Y1+4)
  420.  
  421. #define    FSEL_MAKE_X    (FSEL_X1+11*8)
  422. #define    FSEL_MAKE_Y    (FSEL_Y1+1*24+4)
  423.  
  424. #define    FSEL_KEYW_X    (FSEL_X1+11*8)
  425. #define    FSEL_KEYW_Y    (FSEL_Y1+2*24+4)
  426.  
  427. #define    FSEL_COPY_X    (FSEL_X1+11*8)
  428. #define    FSEL_COPY_Y    (FSEL_Y1+3*24+4)
  429.  
  430. #define    FSEL_READ_X    (FSEL_X1+11*8)
  431. #define    FSEL_READ_Y    (FSEL_Y1+4*24+4)
  432.  
  433. #define    FSEL_MANU_X    (FSEL_X1+11*8)
  434. #define    FSEL_MANU_Y    (FSEL_Y1+5*24+4)
  435.  
  436. #define    FSEL_DIR_X    (FSEL_X1+11*8)
  437. #define    FSEL_DIR_Y    (FSEL_Y1+6*24+4)
  438.  
  439. #define    FSEL_EXT_X    ((FSEL_X1+FSEL_X2)/2-22*8)
  440. #define    FSEL_EXT_Y    (FSEL_Y1+7*24+4)
  441.  
  442. #define    FSEL_YES_X    ((FSEL_X1+FSEL_X2)/2-10*8)
  443. #define    FSEL_YES_Y    (FSEL_Y1+7*24+4)
  444.  
  445. #define    FSEL_RET_X    ((FSEL_X1+FSEL_X2)/2+2*8)
  446. #define    FSEL_RET_Y    (FSEL_Y1+7*24+4)
  447.  
  448. #define LIST_X          (17*8)
  449. #define LIST_Y          26
  450. #define LIST_M          "マニュアル表示"
  451. #define    LIST_X1            (LIST_X-4)
  452. #define    LIST_Y1            (LIST_Y-2)
  453. #define    LIST_X2            (LIST_X+14*8+3)
  454. #define    LIST_Y2            (LIST_Y+17)
  455.  
  456. #define KEY_X           8
  457. #define KEY_Y           69
  458. #define KEY_L            (18*8)
  459. #define KEY_S            (20*8)
  460. #define KEY_POS_X(n)    ((n%4)*KEY_S+KEY_X)
  461. #define KEY_POS_Y(n)    ((n/4)*24+KEY_Y)
  462.  
  463. void    eof_chk(FILE *fp)
  464. {
  465.     int     ch;
  466.  
  467.     _setmode(fp,_BINARY);
  468.     fseek(fp,(-50L),SEEK_END);
  469.     while ( (ch = getc(fp)) != EOF && ch != 0x1A );
  470.     if ( ch == 0x1A ) {
  471.     fseek(fp,(-1L),SEEK_CUR);
  472.     } else {
  473.     clearerr(fp);
  474.     fseek(fp,0L,SEEK_END);
  475.     }
  476.     _setmode(fp,_TEXT);
  477. }
  478.  
  479. void    KEY_input(void)
  480. {
  481.     int     i,n,j;
  482.     int     sw,bx,by;
  483.     FILE    *fp;
  484.     BLOCK   *sp;
  485.     EVENT   *ep=NULL;
  486.     PRGPTR  *pp;
  487.     char    *p,*s;
  488.     char    tmp[256];
  489.     char    key[BUFSIZ];
  490.     static char dmy[7][BUFSIZ];
  491.  
  492.     if ( (fp = fopen(FILE_IDX,"r+")) == NULL ) {
  493.     if ( (fp = fopen(FILE_IDX,"w")) == NULL )
  494.         return;
  495.     } else
  496.     eof_chk(fp);
  497.  
  498.     dmy[0][0] = dmy[1][0] = dmy[2][0] = dmy[3][0] = 
  499.     dmy[4][0] = dmy[5][0] = dmy[6][0] = '\0';
  500.  
  501.     MOS_disp(OFF);
  502.     sp = DSP_push_vram(FSEL_X1,FSEL_Y1,FSEL_X2,FSEL_Y2);
  503.     DSP_opbox(FSEL_X1,FSEL_Y1,FSEL_X2,FSEL_Y2);
  504.     DSP_wbox(FSEL_X1,FSEL_Y1,FSEL_X2,FSEL_Y2,LINE_COL,MENU_COL,M_PSET);
  505.  
  506.     ep = EVT_set(ep,500,LIST_X1,LIST_Y1,LIST_X2,LIST_Y2,EVT_proc);
  507.  
  508.     for ( i = 0 ; i < 28 ; i++ ) {
  509.     ep = EVT_set(ep,i+300,
  510.          KEY_POS_X(i)-4,KEY_POS_Y(i)-2,
  511.          KEY_POS_X(i)+KEY_L+3,KEY_POS_Y(i)+17,EVT_proc);
  512.     }
  513.  
  514.     sprintf(tmp,"%-44.44s",dmy[0]);
  515.     ep = EVT_sw(ep,0,FSEL_PROG_X,FSEL_PROG_Y,CHR_COL,WIND_COL,tmp);
  516.     sprintf(tmp,"%-31.31s",dmy[1]);
  517.     ep = EVT_sw(ep,1,FSEL_MAKE_X,FSEL_MAKE_Y,CHR_COL,WIND_COL,tmp);
  518.     sprintf(tmp,"%-58.58s",dmy[2]);
  519.     ep = EVT_sw(ep,2,FSEL_KEYW_X,FSEL_KEYW_Y,CHR_COL,WIND_COL,tmp);
  520.     sprintf(tmp,"%-58.58s",dmy[3]);
  521.     ep = EVT_sw(ep,3,FSEL_COPY_X,FSEL_COPY_Y,CHR_COL,WIND_COL,tmp);
  522.     sprintf(tmp,"%-58.58s",dmy[4]);
  523.     ep = EVT_sw(ep,4,FSEL_READ_X,FSEL_READ_Y,CHR_COL,WIND_COL,tmp);
  524.     sprintf(tmp,"%-58.58s",dmy[5]);
  525.     ep = EVT_sw(ep,5,FSEL_MANU_X,FSEL_MANU_Y,CHR_COL,WIND_COL,tmp);
  526.     sprintf(tmp,"%-58.58s",dmy[6]);
  527.     ep = EVT_sw(ep,6,FSEL_DIR_X,FSEL_DIR_Y,CHR_COL,WIND_COL,tmp);
  528.  
  529.     ep = EVT_sw(ep,10,FSEL_X1+8,FSEL_PROG_Y,CHR_COL,KEY_COL,"PROGRAM");
  530.     ep = EVT_sw(ep,11,FSEL_X1+8,FSEL_MAKE_Y,CHR_COL,KEY_COL,"MAKE   ");
  531.     ep = EVT_sw(ep,12,FSEL_X1+8,FSEL_KEYW_Y,CHR_COL,KEY_COL,"KEYWORD");
  532.     ep = EVT_sw(ep,13,FSEL_X1+8,FSEL_COPY_Y,CHR_COL,KEY_COL,"COPY   ");
  533.     ep = EVT_sw(ep,14,FSEL_X1+8,FSEL_READ_Y,CHR_COL,KEY_COL,"README ");
  534.     ep = EVT_sw(ep,15,FSEL_X1+8,FSEL_MANU_Y,CHR_COL,KEY_COL,"MANUAL ");
  535.     ep = EVT_sw(ep,16,FSEL_X1+8,FSEL_DIR_Y, CHR_COL,KEY_COL,"DIR    ");
  536.  
  537.     ep = EVT_sw(ep,110,FSEL_EXT_X,FSEL_EXT_Y,CHR_COL,WIND_COL," 簡  単 ");
  538.     ep = EVT_sw(ep,100,FSEL_YES_X,FSEL_YES_Y,CHR_COL,WIND_COL," 設  定 ");
  539.     ep = EVT_sw(ep,200,FSEL_RET_X,FSEL_RET_Y,CHR_COL,WIND_COL," もどる ");
  540.  
  541.     MOS_rdpos(&sw,&bx,&by);
  542.     MOS_setpos((FSEL_X1+FSEL_X2)/2,(FSEL_Y1+FSEL_Y2)/2);
  543.     MOS_disp(ON);
  544.  
  545.     for ( ; ; ) {
  546.     i = EVT_wait(ep);
  547.  
  548.     if ( i == 0 ) {
  549.         MOS_disp(OFF);
  550.         input(FSEL_PROG_X,FSEL_PROG_Y+i*24,44,dmy[i]);
  551.         MOS_disp(ON);
  552.  
  553.     } else if ( i == 1 ) {
  554.         MOS_disp(OFF);
  555.         input(FSEL_PROG_X,FSEL_PROG_Y+i*24,31,dmy[i]);
  556.         MOS_disp(ON);
  557.  
  558.     } else if ( i >= 2 && i <= 6 ) {
  559.         MOS_disp(OFF);
  560.         input(FSEL_PROG_X,FSEL_PROG_Y+i*24,58,dmy[i]);
  561.         MOS_disp(ON);
  562.  
  563.     } else if ( i >= 10 && i <= 11 ) {
  564.         if ( (p = FILE_select()) != NULL ) {
  565.         MENU_mask(RETN_NO,ON);
  566.         cut_mode = TRUE;
  567.         FILE_open(p);
  568.         while ( MENU_no(0) != CLER_NO )
  569.             FILE_irq();
  570.         MENU_mask(CLER_NO,OFF);
  571.         FILE_close();
  572.         cut_mode = FALSE;
  573.  
  574.         n = i - 10;
  575.         strcat(dmy[n],cut_buf[0]);
  576.  
  577.         MOS_disp(OFF);
  578.         gprintf(FSEL_PROG_X,FSEL_PROG_Y+n*24,
  579.             CHR_COL,WIND_COL,
  580.              n == 0 ? "%-44.44s":
  581.             (n == 1 ? "%-31.31s":
  582.                   "%-58.58s"),dmy[n]);
  583.         MOS_disp(ON);
  584.         }
  585.  
  586.     } else if ( i == 110 ) {
  587.         if ( (p = FILE_select()) != NULL ) {
  588.         MENU_mask(RETN_NO,ON);
  589.         cut_mode = TRUE;
  590.         FILE_open(p);
  591.         while ( MENU_no(0) != CLER_NO )
  592.             FILE_irq();
  593.         MENU_mask(CLER_NO,OFF);
  594.         FILE_close();
  595.         cut_mode = FALSE;
  596.  
  597.         strcpy(dmy[0],cut_buf[0]);
  598.         strcpy(dmy[1],cut_buf[1]);
  599.         getdir(dmy[6]);
  600.  
  601.         MOS_disp(OFF);
  602.         gprintf(FSEL_PROG_X,FSEL_PROG_Y,
  603.             CHR_COL,WIND_COL,"%-44.44s",dmy[0]);
  604.         gprintf(FSEL_MAKE_X,FSEL_MAKE_Y,
  605.             CHR_COL,WIND_COL,"%-31.31s",dmy[1]);
  606.             CHR_COL,WIND_COL,
  607.         gprintf(FSEL_DIR_X,FSEL_DIR_Y,
  608.             CHR_COL,WIND_COL,"%-58.58s",dmy[6]);
  609.             MOS_disp(ON);
  610.         }
  611.  
  612.     } else if ( i >= 13 && i <= 15 ) {
  613.         if ( (p = FILE_select()) != NULL ) {
  614. /********************************************
  615.         tmp[0] = 'A' + getdrv();
  616.         tmp[1] = ':';
  617.         getdir(tmp+2);
  618.         if ( tmp[3] != '\0' )
  619.             strcat(tmp,"\\");
  620.         strcat(tmp,p);
  621. *********************************************/
  622.         getdir(tmp);
  623.         if ( tmp[1] != '\0' )
  624.             strcat(tmp,"\\");
  625.         strcat(tmp,p);
  626.  
  627.         n = i - 10;
  628.         if ( dmy[n][0] != '\0' )
  629.             strcat(dmy[n]," ");
  630.         strcat(dmy[n],tmp);
  631.  
  632.         MOS_disp(OFF);
  633.         gprintf(FSEL_PROG_X,FSEL_PROG_Y+n*24,
  634.                 CHR_COL,WIND_COL,"%-58.58s",dmy[n]);
  635.             MOS_disp(ON);
  636.         }
  637.  
  638.     } else if ( i == 16 ) {
  639.         FILE_select();
  640. /*******************************************
  641.         tmp[0] = 'A' + getdrv();
  642.         tmp[1] = ':';
  643.         getdir(tmp+2);
  644. *******************************************/
  645.         getdir(tmp);
  646.  
  647.         n = i - 10;
  648.         strcpy(dmy[n],tmp);
  649.  
  650.         MOS_disp(OFF);
  651.         gprintf(FSEL_PROG_X,FSEL_PROG_Y+n*24,
  652.             CHR_COL,WIND_COL,"%-58.58s",dmy[n]);
  653.         MOS_disp(ON);
  654.  
  655.     } else if ( i == 500 ) {
  656.         LIST_proc();
  657.  
  658.     } else if ( i >= 300 ) {
  659.         if ( key_tbl[i-300] != NULL ) {
  660.         if ( dmy[2][0] != '\0' )
  661.             strcat(dmy[2]," ");
  662.         strcat(dmy[2],key_tbl[i-300]->key);
  663.         MOS_disp(OFF);
  664.         gprintf(FSEL_KEYW_X,FSEL_KEYW_Y,
  665.                 CHR_COL,WIND_COL,"%-58.58s",dmy[2]);
  666.         MOS_disp(ON);
  667.         }
  668.  
  669.     } else if ( i == 100 ) {
  670.         if ( dmy[0][0] == '\0' &&
  671.         yesno("作品名が無いけど?") == ERR )
  672.         continue;
  673.         if ( dmy[1][0] == '\0' &&
  674.         yesno("作者名が無いけど?") == ERR )
  675.         continue;
  676.         if ( dmy[2][0] == '\0' &&
  677.         yesno("キ-ワ-ドが無いけど?") == ERR )
  678.         continue;
  679.         if ( dmy[3][0] == '\0' && dmy[4][0] == '\0' &&
  680.              dmy[5][0] == '\0' && dmy[6][0] == '\0' &&
  681.         yesno("ファイル指定が無いけど?") == ERR )
  682.         continue;
  683.  
  684.         fprintf(fp,"\n");
  685.         fprintf(fp,"PROGRAM: %s\n",dmy[0]);
  686.         fprintf(fp,"MAKE:    %s\n",dmy[1]);
  687.         fprintf(fp,"KEYWORD: %s\n",dmy[2]);
  688.         if ( dmy[3][0] != '\0' )
  689.         fprintf(fp,"COPY:    %s\n",dmy[3]);
  690.         if ( dmy[4][0] != '\0' )
  691.         fprintf(fp,"README:  %s\n",dmy[4]);
  692.         if ( dmy[5][0] != '\0' )
  693.         fprintf(fp,"MANUAL:  %s\n",dmy[5]);
  694.         if ( dmy[6][0] != '\0' )
  695.         fprintf(fp,"DIR:     %s\n",dmy[6]);
  696.  
  697.         if ( (pp = (PRGPTR *)malloc(sizeof(PRGPTR))) == NULL )
  698.         break;
  699.         pp->next = prg_top;
  700.         prg_top = pp;
  701.         prg_max++;
  702.         pp->flg = pp->copycnt = pp->bits = 0;
  703.         pp->name = strdup(dmy[0]);
  704.         pp->make = pp->readme = pp->manual = pp->dir = NULL;
  705.  
  706.         if ( dmy[1][0] != '\0' )
  707.         pp->make = strdup(dmy[1]);
  708.         if ( dmy[4][0] != '\0' )
  709.         pp->readme = strdup(chk_drv(dmy[4]));
  710.         if ( dmy[5][0] != '\0' )
  711.         pp->manual = strdup(chk_drv(dmy[5]));
  712.         if ( dmy[6][0] != '\0' )
  713.         pp->dir    = strdup(chk_drv(dmy[6]));
  714.  
  715.         p = dmy[3];
  716.         while ( *p != '\0' ) {
  717.         while ( isspace(*p) ) p++;
  718.         for ( s = key ; !isspace(*p) && *p != '\0' ; )
  719.              *(s++) = *(p++);
  720.         *s = '\0';
  721.         if ( key[0] != '\0' && pp->copycnt < 16 )
  722.             pp->copy[pp->copycnt++] = strdup(chk_drv(key));
  723.         }        
  724.  
  725.         p = dmy[2];
  726.         while ( *p != '\0' ) {
  727.         while ( isspace(*p) ) p++;
  728.         for ( s = key ; !isspace(*p) && *p != '\0' ; )
  729.              *(s++) = *(p++);
  730.         *s = '\0';
  731.         if ( key[0] != '\0' )
  732.             key_set(key,pp);
  733.         }        
  734.  
  735.         dmy[0][0] = dmy[1][0] = dmy[2][0] = dmy[3][0] = 
  736.         dmy[4][0] = dmy[5][0] = dmy[6][0] = '\0';
  737.  
  738.         MOS_disp(OFF);
  739.         gprintf(FSEL_PROG_X,FSEL_PROG_Y,
  740.             CHR_COL,WIND_COL,"%-44.44s",dmy[0]);
  741.         gprintf(FSEL_MAKE_X,FSEL_MAKE_Y,
  742.             CHR_COL,WIND_COL,"%-31.31s",dmy[1]);
  743.         gprintf(FSEL_KEYW_X,FSEL_KEYW_Y,
  744.             CHR_COL,WIND_COL,"%-58.58s",dmy[2]);
  745.         gprintf(FSEL_COPY_X,FSEL_COPY_Y,
  746.             CHR_COL,WIND_COL,"%-58.58s",dmy[3]);
  747.         gprintf(FSEL_READ_X,FSEL_READ_Y,
  748.             CHR_COL,WIND_COL,"%-58.58s",dmy[4]);
  749.         gprintf(FSEL_MANU_X,FSEL_MANU_Y,
  750.             CHR_COL,WIND_COL,"%-58.58s",dmy[5]);
  751.         gprintf(FSEL_DIR_X,FSEL_DIR_Y,
  752.             CHR_COL,WIND_COL,"%-58.58s",dmy[6]);
  753.         MOS_disp(ON);
  754.  
  755.     } else if ( i == 200 ) {
  756.         break;
  757.     }
  758.     }
  759.  
  760.     EVT_free(ep);
  761.     MOS_disp(OFF);
  762.     DSP_pop_vram(sp);
  763.     MOS_setpos(bx,by);
  764.     MOS_disp(ON);
  765.     fclose(fp);
  766. }
  767.